package com.fhzn.auth.web.converter;

import com.fhzn.auth.entity.User;
import com.fhzn.auth.tools.DateTimeUtils;
import com.fhzn.auth.web.vo.UserVO;

/**
 * @author 老顾
 * @apiNote
 * @since 2023/12/27
 */
public interface UserConverter {

    /**
     * 用户实体转换
     *
     * @param user 请求参数
     * @return 返回参数
     */
    static UserVO fromUser(User user) {
        UserVO userVO = new UserVO();
        if (user != null) {
            userVO.setId(user.getId());
            userVO.setNickname(user.getNickname());
            userVO.setNicknameCn(user.getNicknameCn());
            userVO.setStatus(user.getStatus());
            userVO.setUserType(user.getUserType());
            userVO.setUserExt(user.getUserExt());
            userVO.setMobile(user.getMobile());
            userVO.setTel(user.getTel());
            userVO.setAppCode(user.getAppCode());
            userVO.setRoles(user.getRoles());
            userVO.setLeaderMap(user.getLeaderMap());
            userVO.setLeaderStr(user.getLeaderStr());
            userVO.setTimesegments(user.getTimeSegments());
            userVO.setPasswordExpired(user.getPasswordExpired());
            userVO.setRealname(user.getRealname());
            userVO.setIdno(user.getIdno());
            userVO.setSex(user.getSex());
            userVO.setEmail(user.getEmail());
            userVO.setOrganizationId(user.getOrganizationId());
            userVO.setCreatedTime(DateTimeUtils.format(user.getCreatedTime()));
            userVO.setSn(user.getSn());
            userVO.setOrgShort(user.getOrgShort());
        }
        return userVO;
    }
}
